#ifndef IPERSISTENCE_ASSISTANT_H
#define IPERSISTENCE_ASSISTANT_H

#include <QtCore/QSharedPointer>

QT_BEGIN_NAMESPACE
class QUrl;
QT_END_NAMESPACE

namespace core
{
class IDocument;
class IPersistentDocument;
class IStorage;
class MimeType;
class Persistence;

class IPersistenceAssistant
{
public:
    virtual bool canOpen(const MimeType& mimeType) const = 0;
    virtual bool canSave(const MimeType& mimeType) const = 0;
    virtual bool isNative(const QSharedPointer<IPersistentDocument>&
        document) const = 0;
    virtual bool isNative(const MimeType& mimeType) const = 0;
    virtual QString forStorage() const = 0;

    virtual QSharedPointer<IDocument> open() = 0;
    virtual QSharedPointer<IDocument> openFuture() = 0;
    virtual QSharedPointer<IPersistentDocument> save() = 0;
    virtual void closeAndKeepFuture() = 0;

    virtual QSharedPointer<IDocument> getDocument() const = 0;
    virtual QSharedPointer<IPersistentDocument> getPersistentDocument(
        ) const = 0;

    virtual ~IPersistenceAssistant() {}

protected:
    friend class Persistence;

    virtual IPersistenceAssistant* copy() const = 0;

    virtual bool createPersistentDocument(const QUrl& url,
        const IStorage* storage) = 0;

    virtual void setDocument(const QSharedPointer<IDocument>& document) = 0;
    virtual void setPersistentDocument(
        const QSharedPointer<IPersistentDocument>& document) = 0;
};

} // namespace core

#endif
